< previous page page_565 next page >

Page 565
9f31265bb40b592b1929e18a47ab28e5.gif
   End With
End Sub
Limiting Characters in a Combo Box
If you have a combo box with the Style property set to 0 - Dropdown Combo, you might want to limit the number of characters the user can type into the text box portion of the combo box. The combo box control does not have a MaxLength property like the text box control; therefore, youll need to use the SendMessage() API call.
Examples Filename: ApiCombo.frm
In the example shown in Figure 28.6, you have a list of state codes in the combo box. You want to allow the users to enter additional state codes, so you need to limit them to two characters. The following code shows you the call you use to accomplish this:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub Form_Load()
   Dim lngRet As Long

   ' Limit the text portion of
   ' the combo box to 2 characters
   lngRet = SendMessage(cboStates.hwnd, _
                        CB_LIMITTEXT, _
                        2, _
                        0&)

   Call StateLoad
End Sub
8160-0565a.gif
Figure 28.6
Limiting characters in a combo box.

 
< previous page page_565 next page >

If you like this book, buy it!